// Flutter imports:
import 'package:flutter/material.dart';

// Package imports:
import 'package:get/get.dart';

// Project imports:
import 'package:palmf_hid/common/values/values.dart';
import 'setting_logic.dart';

class SettingComponent extends StatefulWidget {
  @override
  State<SettingComponent> createState() => _CalibrationParamPageState();
}

class _CalibrationParamPageState extends State<SettingComponent> {
  final logic = Get.put(SettingLogic());
  final state = Get.find<SettingLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Obx(()=> Column(
      children: [
        const SizedBox(height: 20,),
        Text('setting'.tr),
        const Divider(),
        ListTile(
            dense: true,
            leading: Container(
              width: 30,
              alignment: Alignment.center,
              child: const Icon(
                Icons.info,
                color: MyColor.c_FF0F53A2,
              ),
            ),
            title: Text('versionName'.tr),
            subtitle: Text(state.appVersionName.value == ""
                ? ""
                : state.appVersionName.value),
            trailing:
            const Icon(Icons.chevron_right, color: MyColor.c_FF0F53A2),
            onTap: () {
              logic.checkUpdate();
            }),
        const Divider(
          height: 1,
        ),
        ListTile(
          dense: true,
          leading: Container(
            width: 30,
            alignment: Alignment.center,
            child: const Icon(
              Icons.font_download,
              color: MyColor.c_FF0F53A2,
            ),
          ),
          title: Text('language'.tr),
          subtitle: Text(state.languageChange.value ? "中文" : "English"),
          trailing: Switch(
              activeColor: MyColor.c_FF0F53A2,
              onChanged: (bool value) {
                logic.changeLocal();
              },
              value: state.languageChange.value),
        ),
      ],
    ));
  }

  @override
  void dispose() {
    Get.delete<SettingLogic>();
    super.dispose();
  }
}
